<?php
class OrderAction extends CommonAction {
	public function index(){
	echo ('ORDER INDEX');
	}
	public function web(){
	$username = session('username');
			$account = D('Order'); // 实例化模型类
			$count=$account->count();
			import('ORG.Util.Page');
			$page=new Page($count,20);//后台管理页面默认一页显示8条文章记录
			$page->setConfig('prev', "上一页");//上一页
			$page->setConfig('next', '下一页');//下一页
			$page->setConfig('first', '首页');//第一页
			$page->setConfig('last', '尾页');//最后一页
			$page->setConfig('theme',' %first% %upPage%  %linkPage%  %downPage% %end%');
			$show=$page->show();
			$firstpage=$page->firstRow;
			$lastpage=$page->listRows;
			$list=$account->query("select * from ys_order where orderuser='$username' and ordertype='网站建设' limit $firstpage,$lastpage");
			$this->assign('accounts_list', $list); // 数据列表变量赋值
			$this->assign('page_method',$show);//分页列表变量赋值
			$this->display(); // 输出模板
	}
	public function seo(){
	echo ('ORDER  SEO INDEX');
	}
	public function up() {
  $this->display();
}

// 文件上传
 public function upload() {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();// 实例化上传类
     $upload->maxSize  = 125829120 ;// 设置附件上传大小
     $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg','rar','zip');// 设置附件上传类型
     $upload->savePath =  './Public/Uploads/';// 设置附件上传目录
	 $upload->saveRule = '';
     if(!$upload->upload()) {// 上传错误提示错误信息
         $this->error($upload->getErrorMsg());
     }else{// 上传成功
	 $info =  $upload->getUploadFileInfo();
	 $filename=$info[0]["savename"];
	//echo($filename);
	$this->assign('filename', $filename); // 数据列表变量赋值
	$this->show('<script language=javascript>
		var filename="{$filename}";
		alert(filename);
window.opener.document.form1.accessories.value="/Public/Uploads/"+filename;
window.opener=null;
window.close();
</script>');
     }
 }
public function newsave(){
	$username = session('username');
    	$newuser = M('Order'); // 实例化模型类  
		if($newuser->create()){
		$newuser->ordertime = date('Y-m-d H:i:s');
		$newuser->orderuser =$username;
		$newuser->wangzhi =$_POST['wangzhi'];
		$newuser->ordertype='网站建设';
		$vo=$newuser->add();
		//$this->show('<script type="text/javascript" src="__PUBLIC__/libs/js/jquery.js"></script><script type="text/javascript">$(function(){top.Dialog.alert("成功提交",function(){window.parent.frmright.location.href="/index.php/Order/web";top.Dialog.close()})})</script>','utf-8');
		$this->success('成功提交');
        }
		else {
		echo '信息添加失败，请检查网络！';
    }
	}
	public function edit(){
	$custom=M('Order');
		$id=$_GET['id'];
		$custom_item=$custom->where("id=$id")->find();
		//dump($custom_item);
		$this->assign('id',$custom_item["id"]);
		$this->assign('jine',$custom_item["jine"]);
		$this->assign('company',$custom_item["company"]);
		$this->assign('wangzhi',$custom_item["wangzhi"]);
		$this->assign('content',$custom_item["content"]);
		$this->assign('accessories',$custom_item["accessories"]);
		$this->assign('endtime',$custom_item["endtime"]);
		$this->display();
	}
	public function editsave(){
		header("Content-Type:text/html; charset=utf-8");
		$custom=M('Order');
		//$id=$_GET['id'];
		$content=stripslashes($_POST['content']);
		$data['id']=$_GET['id'];
		$data['company']=$_POST['company'];
		$data['jine']=$_POST['jine'];
		$data['wangzhi']=$_POST['wangzhi'];
		$data['endtime']=$_POST['endtime'];
		$data['content']=$content;
		$data['accessories']=$_POST['accessories'];
		//echo($content);
		$custom->save($data); // 根据条件保存修改的数据
		$this->show('<script type="text/javascript" src="__PUBLIC__/libs/js/jquery.js"></script><script type="text/javascript">$(function(){top.Dialog.alert("修改成功！",function(){window.parent.frmright.location.href="/index.php/Order/web";top.Dialog.close()})})</script>','utf-8');
	}
}
?>